# -*- coding: utf-8 -*-
# @Time    : 2024/8/30 下午1:36
# @Author  : wb
# @Email   : wb@163.com
# @File    : task_add_page.py
# @Software: PyCharm

from time import sleep
from pages.wb_base_page import BasePage
from selenium.webdriver.common.by import By

class TaskModifyPage(BasePage):
    url = '/crm'
    # 定位器
    '''获取主题输入框元素'''
    subject_locator = (By.NAME, 'subject')
    '''获取描述输入框元素'''
    descript_locator = (By.CSS_SELECTOR, 'body')
    '''获取保存按钮元素'''
    save_btn_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div > form > table > thead > tr > td:nth-child(2) > input.btn.btn-primary')

    # 浏览器操作
    def clear_subject(self,):
        '''清理主题输入框'''
        self.driver.find_element(*self.subject_locator).clear()
    def modify_input_subject(self,subject):
        '''主题框输入1字符'''
        self.driver.find_element(*self.subject_locator).send_keys(subject)
    def switch_frame(self):
        '''切换frame'''
        self.driver.switch_to.frame(self.driver.find_element(By.CSS_SELECTOR,'body > div.container > div.row > div > form > table > tbody > tr:nth-child(8) > td:nth-child(2) > div > div.ke-edit > iframe'))
        sleep(2)
    def clear_descript(self):
        '''清理描述输入框'''
        self.driver.find_element(*self.descript_locator).clear()
    def modify_input_descript(self,descript):
        '''描述框输入5字符'''
        self.driver.find_element(*self.descript_locator).send_keys(descript)
    def switch_main_frame(self):
        '''切换frame到主文档'''
        self.driver.switch_to.default_content()
    def modify_click_save(self):
        '''点击保存'''
        self.driver.find_element(*self.save_btn_locator).click()


